package com.ham.mapper;

import cn.dev.mybatis.annotation.Mapper;
import cn.dev.mybatis.annotation.Delete;
import cn.dev.mybatis.annotation.Insert;
import cn.dev.mybatis.annotation.Select;
import cn.dev.mybatis.annotation.Update;
import com.ham.entity.User;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
    @Insert("insert into t_user(name, age, address) values(#{name}, #{age}, #{address})")
    int save(User user);

    @Delete("delete from t_user where id = #{id}")
    int deleteById(Long id);

    @Update("update t_user set name = #{name}, age = #{age}, address = #{address} where id = #{id}")
    int update(User user);

    @Select("select * from t_user where id = #{id}")
    User findById(Long id);

    @Select("select * from t_user where id = #{id}")
    Map<String, Object> findByIdForMap(Long id);

    @Select("select * from t_user")
    List<User> list();

    @Select("select * from t_user")
    List<Map<String, Object>> listForMap();
}
